import {
	CalendarViewActionType,
	ICalendarViewAbility,
	IParam,
} from '@/core/interface';
import { ICalendarViewController } from '@/core/interface/view/controller';
import { ICalendarViewControllerParams } from '@/core/interface/view/controller-params';
import { ICalendarViewStore } from '@/core/interface/view/store';
import {
	ICalendarAbility,
	ISearchFormAbility,
} from '@/core/interface/widgets/ability';
import { deepCopy } from '@/core/utils';
import { MDViewController } from './md-view-controller';

/**
 * 日历视图控制器
 *
 * @export
 * @class CalendarViewController
 * @extends {ViewController}
 */
export class CalendarViewController
	extends MDViewController<
		CalendarViewActionType,
		ICalendarViewStore,
		ICalendarViewAbility
	>
	implements ICalendarViewController<ICalendarViewStore, ICalendarViewAbility>
{
	/**
	 * 处理视图初始化
	 *
	 * @protected
	 * @param {ICalendarViewControllerParams<CalendarViewActionType, ICalendarViewAbility>} params
	 * @memberof CalendarViewController
	 */
	protected processViewInit(
		params: ICalendarViewControllerParams<
			CalendarViewActionType,
			ICalendarViewAbility
		>
	) {
		super.processViewInit(params);
	}

	/**
	 * 获取日历部件能力
	 *
	 * @protected
	 * @return {*}  {(ICalendarAbility | undefined)}
	 * @memberof CalendarViewController
	 */
	protected getMainCtrlAbility(): ICalendarAbility | undefined {
		const calendar = this.model.ctrls.find(
			(ctrl: IParam) => ctrl.controlType === 'CALENDAR'
		);
		if (calendar) {
			return this.getSubAbility<ICalendarAbility>(calendar.name);
		}
		return undefined;
	}
}
